package com.jvxb.manage.livable.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jvxb.manage.livable.entity.SysPermission;
import com.jvxb.manage.livable.mapper.SysPermissionMapper;
import com.jvxb.manage.livable.service.SysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 系统权限表 服务实现类
 * </p>
 *
 * @author jvxb
 * @since 2020-06-07
 */
@Service
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission> implements SysPermissionService {

    @Autowired
    private SysPermissionMapper sysPermissionMapper;

    @Override
    public List<SysPermission> getPermissionBySysUserId(Long userId) {
        if(userId == null) {
            return null;
        }
        List<SysPermission> sysPermissionList = sysPermissionMapper.getPermissionBySysUserId(userId);
        return sysPermissionList;
    }

    @Override
    public IPage<SysPermission> getPermissionByParentId(Integer pid, Integer current, Integer size) {
        IPage<SysPermission> page = new Page<>(current, size);
        IPage<SysPermission> pageResult = baseMapper.getPermissionByParentId(page, pid);
        return pageResult;
    }
}
